package cn.hairui.blog.repository;

import cn.hairui.blog.mapper.ToolMapper;
import cn.hairui.blog.model.Tool;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

/**
 * @author lihairui
 * @version V1.0
 * @date: 2019/7/28 22:26
 */
@Repository
public class ToolRepository {

    @Autowired
    private ToolMapper toolMapper;

    public List<Tool> findLimited(int count) {
        return toolMapper.findLimited(count);
    }

    public Tool find(int id) {
        return toolMapper.find(id);
    }

    public List<Map> listMgr() {
        return toolMapper.listMgr();
    }

    public int add(Tool tool) {
        toolMapper.insert(tool);
        return tool.getId();
    }

    public void update(Tool tool) {
        toolMapper.update(tool);
    }

    public void delete(int id) {
        toolMapper.deleteById(id);
    }

    public List<Tool> list() {
        return toolMapper.list();
    }
}
